package com.sdy.dataexchange.meta.util;

/**
 * @author: 王越洋
 * @version: v1.0
 * @description: com.sdy.dataexchange.meta.util
 * @date:2019/10/31
 */
public class ConstantUtil {

    public static final String ORACLE_ALL_TABLE = "SELECT TABLE_NAME,TABLESPACE_NAME FROM( SELECT a.*, ROWNUM rn FROM " +
            "( SELECT * FROM user_tables ) a WHERE ROWNUM <= %d ) WHERE rn > %d";

    public static final String MYSQL_ALL_TABLE = "select TABLE_SCHEMA,TABLE_NAME,TABLE_COMMENT from information_schema.tables " +
            "where table_schema = %s LIMIT %d,%d";

    public static final String MYSQL_TABLE_COLUMNS = "select TABLE_NAME,COLUMN_NAME," +
            "CASE IS_NULLABLE WHEN 'YES' THEN '是' ELSE '否' END data_empty,DATA_TYPE,COLUMN_TYPE AS data_length," +
            "CASE COLUMN_KEY WHEN 'PRI' THEN '是' ELSE '否' END data_key,COLUMN_COMMENT AS comments from information_schema.columns " +
            "where table_schema = %s and table_name = %s ORDER BY ORDINAL_POSITION";

    public static final String ORACLR_TABLE_COLUMNS =
            "SELECT utc.table_name AS table_name,utc.column_name AS column_name,utc.data_type AS data_type," +
                    "utc.data_length AS data_length,CASE utc.nullable WHEN 'N' THEN '0' ELSE '1' END data_empty," +
                    "utc.data_default AS data_default," +
                    "ucc.comments AS comments,CASE utc.column_name WHEN (SELECT usc.column_name FROM user_constraints uc," +
                    "user_cons_columns usc WHERE uc.constraint_name = usc.constraint_name AND uc.constraint_type = 'P'" +
                    " AND usc.table_name = %s ) THEN '1' ELSE '0' END data_key FROM user_tab_columns utc," +
                    "user_col_comments ucc WHERE utc.table_name = ucc.table_name AND utc.column_name = ucc.column_name" +
                    " AND utc.table_name = %s ORDER BY column_id";
}
